<!DOCTYPE html>
<html lang="en" class="app">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <link rel="stylesheet" href="Public/common/src/css/bootstrap.css" type="text/css"/>
    <link rel="stylesheet" href="Public/common/src/css/animate.css" type="text/css"/>
    <link rel="stylesheet" href="Public/common/src/css/app.css" type="text/css"/>
    <link rel="stylesheet" href="Public/common/src/css/font-awesome.min.css" type="text/css"/>

</head>
<body class="">
<section class="vbox">
    <section>
        <section class="hbox stretch">
            <!-- /.aside -->
            <section id="content">
                <section class="vbox">
                    <section class="scrollable padder">
                        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
                            <li><a href="<?php echo U('Admin/Index/home')?>"><i class="fa fa-home"></i> 首页</a></li>
                            <li class="active">分类管理</li>
                        </ul>
                        <section class="panel panel-default">
                            <header class="panel-heading">
                                分类管理
                            </header>
                            <div class="row wrapper">
                                <div class="col-sm-4 m-b-xs">
                                    <a href="<?php echo U('addTopCate')?>" class="btn btn-default btn-sm">添加顶级分类</a>
                                </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped b-t b-light">
                                    <thead>
                                    <tr pid=0>
									    <td width="30"></td>
							            <td>分类id</td>
							            <td>分类名称</td>
							            <td>分类排序</td>
							            <td>是否显示</td>
							            <td >操作</td>
                                    </tr>
                                    </thead>
                                    <tbody>                
                                    <?php foreach ($data as $k=>$v){?>                   
                                    <tr cid="<?php echo $v['cid']?>" pid=<?php echo $v['pid']?>>
						        		<td width="30">
						        			<a href="javascript:;" class="glyphicon glyphicon-plus click-btn"></a>
						        		</td>                                    	
                                        <td><?php echo $v['cid']?></td>
										<td><?php echo $v['_name']?></td>
										<td><?php echo $v['csort']?></td>
										<?php if($v['is_show']==1){?>
                
											<td>显示</td>
										<?php }else{?>
											<td>不显示</td>
										
               <?php }?>
                                        <td>
                                            <a href="<?php echo U('addSonCate',array('cid'=>$v['cid']))?>" class="btn btn-default btn-sm">添加子分类</a>
                                            <a href="<?php echo U('edit',array('cid'=>$v['cid']))?>" class="btn btn-default btn-sm">编辑</a>
                                            <a href="javascript:del(<?php echo $v['cid']?>);" class="btn btn-default btn-sm">删除</a>
                                        </td>
                                    </tr>
                                    <?php }?>
                                    </tbody>
                                </table>
                            </div>
							<div class="pagination pagination-sm pull-right">
								<!--<?php echo $data['page']?>-->
							</div>
                        </section>
                    </section>
                </section>
            </section>
        </section>
    </section>
</section>
<script src="Public/common/js/jquery-1.7.2.min.js"></script>
<!-- Bootstrap -->
<script src="Public/common/src/js/bootstrap.js"></script>
<!-- 公共 -->
<script src="Public/common/js/common.js"></script>
<link rel="stylesheet" href="Public/common/css/common.css">
<script type="text/javascript">
	function del(cid)
	{
		if(confirm('确定删除吗?'))
		{
			location.href = 'index.php?m=Admin&c=Cate&a=del&cid=' + cid;
		}
				
	}
</script>
<script type="text/javascript">
        	$(function(){
        		$('tr[pid!=0]').hide();
        		$('.click-btn').toggle(function(){
        			$(this).removeClass('glyphicon-plus').addClass('glyphicon-minus');
        			var cid = $(this).parents('tr').attr('cid');
        			$('tr[pid= ' + cid + ']').show();
        		},function(){
        			$(this).removeClass('glyphicon-minus').addClass('glyphicon-plus');
        			var cid = $(this).parents('tr').attr('cid');
        			//注意用上面的方法继续隐藏会有问题,只能收起子集，如果有孙子集的就做不到了,所以发异步得到所有的自己集合
        			//$('tr[pid='+cid+']').hide(); 
        			$.post("<?php echo U('ajaxJian')?>",{cid:cid},function(data){
        				$.each(data, function(k,v) {    
        					  $('tr[cid='+v+']').hide();                                                         
        				});
        			})
        		})
        	})
</script>
</body>
</html>